package com.yupi.maker.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

@Command(name = "ASCIIArt", version = "ASCIIArt 1.0", mixinStandardHelpOptions = true) //表示这是一个命令行工具, 并且可以显示版本号和帮助信息
public class ASCIIArt implements Runnable { //实现Runnable接口, 重写run方法

    @Option(names = { "-s", "--font-size" }, description = "Font size") //定义一个选项, 用于设置字体大小,用户输入的值会赋给fontSize，通过-s参数实现
    int fontSize = 19;

    @Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli", 
               description = "Words to be translated into ASCII art.")//定义一个参数, 用于设置要转换的文字,用户输入的值会赋给words
    private String[] words = { "Hello,", "picocli" }; //默认值

    @Override
    public void run() {//用户确认之后回车之后会执行这个方法
        // 自己实现业务逻辑
        System.out.println("fontSize = " + fontSize);
        System.out.println("words = " + String.join(",", words));
    }

    public static void main(String[] args) {
        int exitCode = new CommandLine(new ASCIIArt()).execute(args); //将用户输入的参数传递给ASCIIArt对象, 并执行run方法
        System.exit(exitCode); 
    }
}
